#define MSSYSCTL_C
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <signal.h>        //signal()
#include <sys/time.h>    //struct itimerval, setitimer()
#include <libmslog/mslog.h>
#include "mssysctl.h"
#include "mscommon.h"
#include "msmd.h"
//user header
#define FLAG "SYSCTL"

#define procsys_net_igmp_version "/proc/sys/net/ipv4/conf/all/force_igmp_version"

ms_void mssysctl_api_setEth_rpfilter(ms_string stritem,ms_bool flag_enable)
{
	ms_byte cmdbuf[256]={0};
	ms_cmd(cmdbuf, "sysctl  -w   net.ipv4.conf.%s.rp_filter=%d > /dev/null", stritem,flag_enable);
	ms_debug("rp_filter cmd:%s",cmdbuf);
}
ms_void mssysctl_api_setGw_rpfilter(ms_bool flag_enable)
{
	mssysctl_api_setEth_rpfilter("all", flag_enable);
	mssysctl_api_setEth_rpfilter("default", flag_enable);
}
ms_s32 mssysctl_api_getIgmpVersion(ms_void)
{
	ms_byte igmp_version[32]={0};
	msmd_api_read(procsys_net_igmp_version, igmp_version, 2);
	return ms_atoi(igmp_version);
}
ms_void mssysctl_api_setIgmpVersion(ms_u08 igmp_version)
{
	ms_byte cmdbuf[1024]={0};
	ms_verbose("config igmp version to version to %d",igmp_version);
	ms_cmd(cmdbuf, "echo %d > %s",igmp_version ,procsys_net_igmp_version);
}

#undef MSSYSCTL_C